package service.Serviceimpl;

import Dao.NewsDao;
import domain.news;

import java.util.List;

public class newsService {
    NewsDao newsDao=new NewsDao();


    /*
    * 查询所有新闻
    * */
    public List<news> findAll(){
        String sql="SELECT * FROM news\n" +
                "WHERE 1=1\n" +
                "ORDER BY create_time DESC\n" +
                "LIMIT 0,10";

       return newsDao.findAll(sql);

    }

/*修改信息*/
public int update( List list){
    String sql ="update news set title=?,n_body=? where n_id=?";
    return newsDao.update(sql,list);

}
    /*
    * 新增新闻
    * */
    public boolean addnews(String title,String body) {
        String sql="INSERT INTO  news (title,n_body,create_time) VALUES(?,?,?)";

        return    newsDao.addnews(sql,title,body);
    }


    /*
    * 查询单条新闻
    * */

}
